﻿@{
    ViewBag.Title = "Region";
}
@section headSection{
    <script src="/Scripts/echarts.js"></script>
    <script src="/Scripts/macarons.js"></script>
    @*饼图--南丁格尔玫瑰图*@
    <script type="text/javascript">
        //异步加载数据
        $.post('/Admin/MembershipAnalysis/Region', function (jsonText) {
            var myChart = echarts.init(document.getElementById('main1'), 'macarons');
            myChart.setOption({
                title: {
                    text: '会员地域分析图',
                    subtext: '本数据真实有效',
                    x: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: "地区:{b}<br/>总数:{c},占({d}%)"
                },
                legend: {
                    x: 'center',
                    y: 'bottom',
                    data: []
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: { show: true },
                        dataView: { show: true, readOnly: false },
                        magicType: {
                            show: true,
                            type: ['pie', 'funnel']
                        },
                        restore: { show: true },
                        saveAsImage: { show: true }
                    }
                },
                calculable: true,
                series: [
                    {
                        name: '地区',
                        type: 'pie',
                        radius: [30, 110],
                        center: ['50%', '50%'],
                        roseType: 'area',
                        data: []
                    }
                ]

            });

            myChart.showLoading();
            var dataName = [];
            var dataData = [];
            //一、判断格式
            //1.0判断参数是否为字符串
            if (typeof (jsonText) == "string") {
                try {
                    //1.1将字符串尝试转换成json对象
                    //处理 数组字面量表示法的 json字符串：[{},{}]
                    jsonText = eval(jsonText);

                } catch (e) {
                    try {
                        //处理 对象字面量表示法的json字符串：{}
                        jsonText = eval("(" + jsonText + ")");
                    } catch (e) {
                        alert("格式错误：必须为json格式字符串");
                    }

                }

            }
            for (var i = 0; i < jsonText.length; i++) {
                dataName[i] = jsonText[i].MAddress;
                dataData[i] = { value: jsonText[i].GroupSum, name: jsonText[i].MAddress };
            }
            myChart.hideLoading();
            //填入数据
            myChart.setOption({
                legend: {
                    data: dataName
                },
                series: [{
                    data: dataData
                }]
            });
        });
    </script>

    <script type="text/javascript">
        //异步加载数据
        $.post('/Admin/MembershipAnalysis/Region', function (jsonText) {
            var myChart2 = echarts.init(document.getElementById('main2'), 'macarons');
            myChart2.setOption({
                title: {
                    text: '会员地域分析图',
                    subtext: '本数据真实有效',
                    x: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: "地区:{b}<br/>总数:{c},占({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                    data: []
                },
                series: [
                    {
                        name: '地区',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '60%'],
                        data: [],
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }]
            });
            myChart2.showLoading();
            var dataName = [];
            var dataData = [];
            if (typeof (jsonText) == "string") {
                try {
                    jsonText = eval(jsonText);
                } catch (e) {
                    try {
                        jsonText = eval("(" + jsonText + ")");
                    } catch (e) {
                        aler("格式错误：必须为json格式字符串！");
                    }

                }

            }
            for (var i = 0; i < jsonText.length; i++) {
                dataName[i] = jsonText[i].MAddress;
                dataData[i] = { value: jsonText[i].GroupSum, name: jsonText[i].MAddress };

            }
            myChart2.hideLoading();
            myChart2.setOption({
                legend: {
                    data: dataName
                },
                series: [{
                    data: dataData
                }]
            })

        });
    </script>
}
<!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
<div id="main1" style="width: 100%;height:400px;"></div>
<div style="width: 100%;height:40px;"></div>
<div id="main2" style="width: 100%;height:400px;"></div>